#include<stdio.h>
#include<unistd.h>

const int  num = 10;

//创建一个多进程

int main()
{
    int i = 0;
    for(; i < num; i++)
    {

        pid_t id = fork();
        if(id == 0)
        {
            //child
            while(1)
            {
                printf("我是子进程，pid: %d, ppid: %d\n", getpid(),getppid());
                sleep(1);
            }
        }
        else
        {
            //father:             
            printf("子进程被创建，pid: %d\n",id);
        }
        sleep(1);
    }
    while(1)
    {

         printf("我是子进程，pid: %d, ppid: %d\n", getpid(),getppid());
    }
}

